package com.web.kdl.controller.matrix;

import com.web.kdl.common.result.CommonResult;
import com.web.kdl.pojo.dto.AddMatrixDto;
import com.web.kdl.pojo.dto.UpdateMatrixDto;
import com.web.kdl.service.matrix.MatrixService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/matrix")
@RequiredArgsConstructor
public class MatrixController {
    private final MatrixService matrixService;


    //增加阵列
    @PostMapping("/addMatrix")
    public CommonResult addMatrix(@Validated @RequestBody AddMatrixDto addMatrixDto) {
        return matrixService.addMatrix(addMatrixDto);
    }

    //删除阵列
    @DeleteMapping("/deleteMatrix")
    public CommonResult deleteMatrix(Integer id) {
        return matrixService.deleteMatrix(id);
    }

    //获取阵列列表
    @GetMapping("/getMatrixList")
    public CommonResult getMatrixList() {
        return matrixService.getMatrixList();
    }

    //更新阵列
    @PutMapping("/updateMatrix")
    public CommonResult updateMatrix(@Validated @RequestBody UpdateMatrixDto updateMatrixDto) {
        return matrixService.updateMatrix(updateMatrixDto);
    }

    @PostMapping("/getMatrixById")
    public CommonResult getMatrixById(@RequestParam Integer id) {
        return matrixService.getMatrixById(id);
    }



}
